package monkify;

import java.util.Scanner;

public class Monkify {
  public static void main(String[] args) throws Exception {
    Scanner sc = new Scanner(System.in);
    String roundType = sc.nextLine();
    String id = sc.nextLine();
    Monkey monkey;
    if (roundType.equals("INIT")) {
      monkey = new Monkey(id);
      monkey.init(sc);
    } else {
      monkey = Monkey.readFromCache(id);
      monkey.turn(sc);
    }
    sc.close();
    monkey.writeToCache();
  }
}